import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  
  server: {
    cors: true,
    port: 8081,
    open: true,
    base: process.env.NODE_ENV === 'development' ? './' : process.env.NODE_ENV === 'production' ? './' : './',
    proxy: {
      '/dev_api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev_api/, '')
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  }
})
